fix(sdnController): validate L2 network detach before SDN controller delete#3346
Open
ZStack-Robot wants to merge 2 commits into5.5.6from
Open
fix(sdnController): validate L2 network detach before SDN controller delete#3346ZStack-Robot wants to merge 2 commits into5.5.6from
ZStack-Robot wants to merge 2 commits into5.5.6from
Conversation
…r delete Resolves: ZSTAC-80186 Change-Id: I8dcb689b022ad907c12bc1b481fb9d0db1e98d06
Walkthrough在 SDN 控制器的 API 拦截器中新增对移除消息的验证:在移除控制器前查询并检测是否存在关联的 HardwareL2VxlanNetworkPoolVO 池,若存在则抛出异常阻止移除;同时新增对应的错误码常量,并在测试清理中先删除所有 L2 VXLAN 池以避免阻塞删除流程。 Changes
Sequence Diagram(s)(省略 — 变更为较小的验证逻辑,不生成序列图) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 分钟 Poem
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Comment |
Resolves: ZSTAC-80186 Change-Id: Ief74f07715f75fe86ae932a8a0cffc91e4bc36c1
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/src/test/groovy/org/zstack/test/integration/network/sdnController/HardwareVxlanCase.groovy (1)
44-48: 建议限定清理范围,避免无条件删除所有池
queryL2VxlanNetworkPool {}无条件查询会删除当前数据库中所有 VXLAN 池,若测试并发或共享 DB,可能影响其他用例。建议限定到本用例的 zone(或缓存创建的 pool UUID 列表)再删除。🛠️ 参考改法(按 zone 限定)
void clean() { // ZSTAC-80186: delete pools created in createEnv() before env.delete() // removes the SDN controller (which now validates no attached pools) - queryL2VxlanNetworkPool {}.each { pool -> + def zone = env.inventoryByName("zone") as ZoneInventory + queryL2VxlanNetworkPool { conditions = ["zoneUuid=${zone.uuid}"] }.each { pool -> deleteL2Network { uuid = pool.uuid } } env.delete() }
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ZSTAC-80186: Deleting an SDN controller without first detaching its L2 vxlan network pools leaves orphaned L2 networks with broken SDN references.
Root Cause
APIRemoveSdnControllerMsghas no validation in the interceptor. The cascade extensionhandleDeletionCheck()also immediately returns success without checking for attached resources.Fix
Add validation in
SdnControllerApiInterceptorforAPIRemoveSdnControllerMsg: check if anyHardwareL2VxlanNetworkPoolVOstill references this SDN controller UUID. If so, reject the delete with a clear error message asking to detach first.Changes
SdnControllerApiInterceptor.java: Add validate method for APIRemoveSdnControllerMsgCloudOperationsErrorCode.java: Add error code ORG_ZSTACK_SDNCONTROLLER_10031Testing
sync from gitlab !9175